<template>
  <view class="page-container">
     <view class="py-60 h-full flex flex-col items-center">
       <view class="mb-48">
         <view class="font-36 font-bold mb-24 text-center">{{resData.categoryName}}</view>
         <view class="font-26 text-99 mb-24 text-center">考试用时： {{time}}</view>
         <view class="font-26 text-99 text-center mb-24">及格分数： {{resData.passScore}}分</view>
       </view>
       <view class="flex-1">
         <ScoreCircle :score="resData.score" :mnksExamPassScore="resData.passScore" :totalNumber="resData.totalNumber" :correctNumber="resData.correctNumber" ></ScoreCircle>
       </view>
       <view class="flex-1 w-full">
         <view class="w-full flex mb-24">
           <view class="text-center flex-1">试卷题数</view>
           <view class="text-center flex-1">答对题数</view>
           <view class="text-center flex-1">答错题数</view>
         </view>
         <view class="w-full flex mb-32">
           <view class="text-center flex-1">{{resData.totalNumber || 0}}</view>
           <view class="text-center flex-1">{{resData.correctNumber || 0}}</view>
           <view class="text-center flex-1">{{resData.incorrectNumber || 0}}</view>
         </view>
         <view class="w-full flex mb-24">
           <view class="text-center flex-1">试卷满分</view>
           <view class="text-center flex-1">考试得分</view>
           <view class="text-center flex-1">正确率</view>
         </view>
         <view class="w-full flex mb-32">
           <view class="text-center flex-1">{{resData.totalScore || 0}}</view>
           <view class="text-center flex-1">{{resData.score || 0}}</view>
           <view class="text-center flex-1">{{correctRate}}</view>
         </view>
       </view>
     </view>
  </view>
</template>
<script setup>
import { ref,computed} from 'vue'
import {onLoad} from "@dcloudio/uni-app"
import utils from '@/utils/utils.js'
import useUserStore from '@/store/user.js'
const useStore = useUserStore()
import useExam from '@/common/useExam.js'
const {
  ContentRow
} = useExam();
const resData = ref({})
onLoad(async (options) => {
  if(options.params){
    // resData.value = JSON.parse(options.params)
    resData.value = ContentRow.value
    console.log('options',resData.value)
  }
})
const time = computed(() => {
   if(resData.value.useTime<=60){
     return resData.value.useTime+'秒'
   }
   //大于60秒且小于60分钟
   if(resData.value.useTime>60 && resData.value.useTime<=3600){
     return Math.floor(resData.value.useTime/60)+'分'+resData.value.useTime%60+'秒'
   }
   //大于60分钟
   if(resData.value.useTime>3600){
     return Math.floor(resData.value.useTime/3600)+'小时'+Math.floor((resData.value.useTime%3600)/60)+'分'+resData.value.useTime%60+'秒'
   }
})
//正确率
const correctRate = computed(() => {
  if(resData.value.totalNumber){
    return (resData.value.correctNumber/resData.value.totalNumber).toFixed(2)*100+'%'
  }else {
    return 0+'%'
  }
})
</script>
<style scoped lang="scss">
</style>